/* REPLICATION MATERIAL

Paper: Crowds and smiles: Visual opportunity structures and the communication of European political leaders during the Covid-19 pandemic
Authors: Moreno Mancosu, Gaetano Scaduto
Apr 8, 2024

REPLICATION FOR
FIG 2-7
FIG SM6-1/SM8-2
*/

cd "PATH"

********************************************************************************
***** Figure 2
********************************************************************************

use "happy_prepost_nointer",clear
gen model = "Happiness"

append using "group_prepost_nointer"
replace model = "Group Pic" if model==""

clonevar x = _at6
replace x = cond(model == "Happiness", x - 0.05, x + 0.05)
rename _at6 _at6_r
rename x _at6

twoway (scatter _margin _at6 if model=="Happiness") (rcap _ci_lb _ci_ub _at6 if model=="Happiness") ///
(scatter _margin _at6 if model=="Group Pic") (rcap _ci_lb _ci_ub _at6 if model=="Group Pic"),legend ///
(order (1 "Positive emot." "" 3 "Group archetype" "")  position(6) cols(2)) ///
xtitle("Period (Pre pandemic/Pandemic)") xsc(r(-.3 1.3)) xlabel(0 1) xlabel(0 "Pre-" 1 "Post") ytitle("Proportion")

graph export "Figure2.png",replace

********************************************************************************
***** Figure 3
********************************************************************************

use "happy_month_nointer",clear
gen model = "Happiness"

append using "group_month_nointer"
replace model = "Group Pic" if model==""


merge m:1 _at6 using "covid_plot_est.dta"


twoway (line _margin _at6 if model=="Happiness", yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if model=="Happiness", yaxis(1)) ///
(bar deaths_1m _at6 if model=="Happiness", color(grey%20) yaxis(2)), xsc(r(0 35)) ///
legend (order(2 "Pos. Emo." 3 "COVID deaths (EU+UK)") position(6) cols(2)) ///
 xlabel(1 "Mar-19" 8 "Oct-19" 16 "Jun-20" 24 "Feb-21" 32 "Oct-21") xtitle("Month") ///
 ytitle("Percentage", axis(1))  ytitle("Deaths per million", axis(2))

 graph export "Figure3.png",replace
 
********************************************************************************
***** Figure 4
********************************************************************************


twoway (line _margin _at6 if model=="Group Pic", yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if model=="Group Pic", yaxis(1)) ///
(bar deaths_1m _at6 if model=="Group Pic", color(grey%20) yaxis(2)), xsc(r(0 35)) ///
legend (order(2 "Group" 3 "COVID deaths (EU+UK)") position(6) cols(2)) ///
 xlabel(1 "Mar-19" 8 "Oct-19" 16 "Jun-20" 24 "Feb-21" 32 "Oct-21") xtitle("Month") ///
 ytitle("Percentage", axis(1))  ytitle("Deaths per million", axis(2))

 graph export "Figure4.png",replace

********************************************************************************
***** Figure 5
********************************************************************************

use "happy_prepost_inter",clear
gen model = "Happiness"

append using "group_prepost_inter"
replace model = "Group Pic" if model==""

clonevar x = _at6
replace x = cond(_at7 == 0, x - 0.05, x + 0.05)
rename _at6 _at6_r
rename x _at6
 
twoway (scatter _margin _at6 if model=="Happiness" & _at7==0) (rcap _ci_lb _ci_ub _at6 if model=="Happiness"& _at7==0) ///
(scatter _margin _at6 if model=="Happiness" & _at7==1) (rcap _ci_lb _ci_ub _at6 if model=="Happiness"& _at7==1),legend ///
(order (1 "Opposition" "" 3 "Government" "")  position(6) cols(2)) aspectratio(1) ysize(100) xsize(100) plotregion(margin(0 0 0 0)) ///
xtitle("Period (Pre pandemic/Pandemic)") xsc(r(-.3 1.3)) xlabel(0 1) xlabel(0 "Pre-" 1 "Post") ytitle("Proportion (pos. emo.)") name(f4_left,replace) title("Pos. emo.")
 
twoway (scatter _margin _at6 if model=="Group Pic" & _at7==0) (rcap _ci_lb _ci_ub _at6 if model=="Group Pic"& _at7==0) ///
(scatter _margin _at6 if model=="Group Pic" & _at7==1) (rcap _ci_lb _ci_ub _at6 if model=="Group Pic"& _at7==1),legend ///
(order (1 "Opposition" "" 3 "Government" "")  position(6) cols(2)) aspectratio(1) ysize(100) xsize(100) plotregion(margin(0 0 0 0)) ///
xtitle("Period (Pre pandemic/Pandemic)") xsc(r(-.3 1.3)) xlabel(0 1) xlabel(0 "Pre-" 1 "Post") ytitle("Proportion (group)") name(f4_right,replace) title("Group")

graph combine f4_left f4_right, ysize(60) xsize(100) 

graph export "Figure5.png",replace

********************************************************************************
***** Figure 6
********************************************************************************

use "happy_month_inter",clear
gen model = "Happiness"

append using "group_month_inter"
replace model = "Group Pic" if model==""

merge m:1 _at6 using "covid_plot_est.dta"

twoway (line _margin _at6 if model=="Happiness" & _at7==1, yaxis(1)) (rcap _ci_lb _ci_ub _at6 if model=="Happiness" & _at7==1, yaxis(1)) ///
(line _margin _at6 if model=="Happiness" & _at7==0, yaxis(1)) (rcap _ci_lb _ci_ub _at6 if model=="Happiness" & _at7==0, yaxis(1)) ///
(bar deaths_1m _at6 if model=="Happiness", color(grey%20) yaxis(2)), xsc(r(0 35)) ///
legend (order(2 "Pos. Emo. Govmt." 4 "Pos. Emo. Opp." 5 "COVID deaths (EU+UK)") position(6) cols(3)) ///
 xlabel(1 "Mar-19" 8 "Oct-19" 16 "Jun-20" 24 "Feb-21" 32 "Oct-21") xtitle("Month") ///
 ytitle("Percentage", axis(1))  ytitle("Deaths per million", axis(2))

 graph export "Figure6.png",replace

********************************************************************************
***** Figure 7
********************************************************************************

 
 twoway (line _margin _at6 if model=="Group Pic" & _at7==1, yaxis(1)) (rcap _ci_lb _ci_ub _at6 if model=="Group Pic" & _at7==1, yaxis(1)) ///
(line _margin _at6 if model=="Group Pic" & _at7==0, yaxis(1)) (rcap _ci_lb _ci_ub _at6 if model=="Group Pic" & _at7==0, yaxis(1)) ///
(bar deaths_1m _at6 if model=="Group Pic", color(grey%20) yaxis(2)), xsc(r(0 35)) ///
legend (order(2 "Group Govmt." 4 "Group Opp." 5 "COVID deaths (EU+UK)") position(6) cols(3)) ///
 xlabel(1 "Mar-19" 8 "Oct-19" 16 "Jun-20" 24 "Feb-21" 32 "Oct-21") xtitle("Month") ///
 ytitle("Percentage", axis(1))  ytitle("Deaths per million", axis(2))

 graph export "Figure7.png",replace

*******************************************************************************
*************** fig SM6-1 and 6-2
*******************************************************************************

use "commnorm_happy_inter",clear
gen model = "Happiness"
append using "commnorm_group_inter"
replace model = "Group Pic" if model==""

rename _at6 _at_vabbe
rename _at _at6

merge m:1 _at6 using "covid_plot_est.dta"

********************************************************************************
***** Figure SM6-1
********************************************************************************


twoway (line _margin _at6 if model=="Happiness", yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if model=="Happiness", yaxis(1)) ///
(bar deaths_1m _at6 if model=="Happiness", color(grey%20) yaxis(2)), xsc(r(0 35)) ///
legend (order(2 "AME Pos. Emo." 3 "COVID deaths") position(6) cols(2)) ///
 xlabel(1 "Mar-19" 8 "Oct-19" 16 "Jun-20" 24 "Feb-21" 32 "Oct-21") xtitle("Month") ///
 ytitle("AME pos. emo.", axis(1))  ytitle("Deaths per million", axis(2)) yline(0)

 graph export "FigureSM6-1.png",replace
 
********************************************************************************
***** Figure SM6-2
********************************************************************************


twoway (line _margin _at6 if model=="Group Pic", yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if model=="Group Pic", yaxis(1)) ///
(bar deaths_1m _at6 if model=="Group Pic", color(grey%20) yaxis(2)), xsc(r(0 35)) ///
legend (order(2 "AME Group" 3 "COVID deaths") position(6) cols(2)) ///
 xlabel(1 "Mar-19" 8 "Oct-19" 16 "Jun-20" 24 "Feb-21" 32 "Oct-21") xtitle("Month") ///
 ytitle("AME group", axis(1))  ytitle("Deaths per million", axis(2)) yline(0)

 graph export "FigureSM6-2.png",replace
 
*******************************************************************************
*************** fig SM7-1, 7-2, and 7-3
*******************************************************************************
 
use "happy_deaths_nointer.dta",clear
gen model = "Happiness"
append using "group_deaths_nointer.dta"
replace model = "Group Pic" if model==""

rename _at6 _at_vabbe
rename _at7 _at6

********************************************************************************
***** Figure SM7-1
********************************************************************************

twoway (line _margin _at6 if model=="Happiness") ///
(rcap _ci_lb _ci_ub _at6 if model=="Happiness") ///
(line _margin _at6 if model=="Group Pic") ///
(rcap _ci_lb _ci_ub _at6 if model=="Group Pic"), xsc(r(1 10)) ///
legend (order(1 "Pos. Emo." 2 "Group") position(6) cols(2)) ///
 xlabel( 2 "2" 4 "4" 6 "6" 8 "8") xtitle("COVID-19 deaths") ///
 ytitle("Percentage", axis(1))

 graph export "FigureSM7-1.png",replace

********************************************************************************
***** Figure SM7-2
********************************************************************************
 
use "happy_deaths_inter.dta",clear
gen model = "Happiness"

rename _at6 _at_gvmt
rename _at7 _at6

twoway (line _margin _at6 if _at_gvmt==1, yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if _at_gvmt==1, yaxis(1)) ///
(line _margin _at6 if _at_gvmt==0, yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if _at_gvmt==0, yaxis(1)) , xsc(r(1 10)) ///
legend (order(2 "Government" 4 "Opposition") position(6) cols(2)) ///
 xlabel( 2 "2" 4 "4" 6 "6" 8 "8") xtitle("COVID-19 deaths") ///
 ytitle("Percentage - Pos. emo.", axis(1))

 graph export "FigureSM7-2.png",replace
 
********************************************************************************
***** Figure SM7-3
********************************************************************************

use "group_deaths_inter.dta",clear
gen model = "Group Pic"

rename _at6 _at_gvmt
rename _at7 _at6

twoway (line _margin _at6 if _at_gvmt==1, yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if _at_gvmt==1, yaxis(1)) ///
(line _margin _at6 if _at_gvmt==0, yaxis(1)) ///
(rcap _ci_lb _ci_ub _at6 if _at_gvmt==0, yaxis(1)) , xsc(r(1 10)) ///
legend (order(2 "Government" 4 "Opposition") position(6) cols(2)) ///
 xlabel( 2 "2" 4 "4" 6 "6" 8 "8") xtitle("COVID-19 deaths") ///
 ytitle("Percentage - Group", axis(1))

 graph export "FigureSM7-3.png",replace
 
 
*******************************************************************************
*************** Fig SM8-1 and 8-2
*******************************************************************************

********************************************************************************
***** Figure SM8-1
********************************************************************************

use "pre_post_1",replace

twoway (scatter _margin _at6) (rcap _ci_lb _ci_ub _at6 ), ///
xtitle("Period (Pre pandemic/Pandemic)") xsc(r(-.3 1.3)) xlabel(0 1) ///
 xlabel(0 "Pre-" 1 "Post") ytitle("Surgical mask") leg(off)

  graph export "FigureSM8-1.png",replace
 
********************************************************************************
***** Figure SM8-2
********************************************************************************

 
use "lrgen_2_post.dta",replace

twoway (line _margin _at1) (rcap _ci_lb _ci_ub _at1), ///
xtitle("Left-right placement") xsc(r(0 10)) xlabel(0(1)10) ///
ytitle("Surgical mask") leg(off)

  graph export "FigureSM8-2.png",replace
